﻿using Slc.Core.Config;
using System;
using System.Configuration;

namespace Slc.Core
{
    public class ConfigSection : ConfigurationSection
    {
        /// <summary>
        /// 数据库类型
        /// </summary>
        [ConfigurationProperty(ConfigPropertyName.DATABDTYPE, DefaultValue = ConfigPropertyValue.DATADBTYPE_DEFAULT)]
        public string DataDbType
        {
            get
            {
                if (base[ConfigPropertyName.DATABDTYPE] == null || base[ConfigPropertyName.DATABDTYPE].ToString() == "")
                {
                    base[ConfigPropertyName.DATABDTYPE] = ConfigPropertyValue.DATADBTYPE_DEFAULT;
                }
                return (string)base[ConfigPropertyName.DATABDTYPE];
            }
            set
            {
                base[ConfigPropertyName.DATABDTYPE] = value;
            }
        }
        /// <summary>
        /// 数据库兼容版本（现主要用于SQLSERVER 中 2000,2005,2008的版本区分）其它数据库类型也可以使用该值
        /// </summary>
        [ConfigurationProperty(ConfigPropertyName.DBVERSION, DefaultValue = ConfigPropertyValue.DBVERSION_DEFAULT)]
        public string DbVersion
        {
            get
            {
                if (base[ConfigPropertyName.DBVERSION] == null || base[ConfigPropertyName.DBVERSION].ToString() == "")
                {
                    base[ConfigPropertyName.DBVERSION] = ConfigPropertyValue.DBVERSION_DEFAULT;
                }
                return (string)base[ConfigPropertyName.DBVERSION];
            }
            set
            {
                base[ConfigPropertyName.DBVERSION] = value;
            }
        }
        /// <summary>
        /// 日志文件
        /// </summary>
        [ConfigurationProperty(ConfigPropertyName.LOGPATH, DefaultValue = ConfigPropertyValue.LOGPATH_DEFAULT)]
        public string LogPath
        {
            get
            {
                if (base[ConfigPropertyName.LOGPATH] == null || base[ConfigPropertyName.LOGPATH].ToString() == "")
                {
                    base[ConfigPropertyName.LOGPATH] = ConfigPropertyValue.LOGPATH_DEFAULT;
                }
                return (string)base[ConfigPropertyName.LOGPATH];
            }
            set
            {
                base[ConfigPropertyName.LOGPATH] = value;
            }
        }
        /// <summary>
        /// 数据库连接
        /// </summary>
        [ConfigurationProperty(ConfigPropertyName.CONNECTIONSTRING, DefaultValue = ConfigPropertyValue.CONNECTIONSTRING_DEFAULT)]
        public string ConnectionString
        {
            get
            {
                if (base[ConfigPropertyName.CONNECTIONSTRING] == null || base[ConfigPropertyName.CONNECTIONSTRING].ToString() == "")
                {
                    base[ConfigPropertyName.CONNECTIONSTRING] = ConfigPropertyValue.CONNECTIONSTRING_DEFAULT;
                }
                return (string)base[ConfigPropertyName.CONNECTIONSTRING];
            }
            set
            {
                base[ConfigPropertyName.CONNECTIONSTRING] = value;
            }
        }
        /// <summary>
        /// 系统语言类型
        /// </summary>
        [ConfigurationProperty(ConfigPropertyName.LANGUAGE, DefaultValue = ConfigPropertyValue.LANGUAGE_DEFAULT)]
        public string Language
        {
            get
            {
                if (base[ConfigPropertyName.LANGUAGE] == null || base[ConfigPropertyName.LANGUAGE].ToString() == "")
                {
                    base[ConfigPropertyName.LANGUAGE] = ConfigPropertyValue.LANGUAGE_DEFAULT;
                }
                return (string)base[ConfigPropertyName.LANGUAGE];
            }
            set
            {
                base[ConfigPropertyName.LANGUAGE] = value;
            }
        }

        /// <summary>
        /// 数据库操作实例程序集
        /// </summary>
        [ConfigurationProperty(ConfigPropertyName.HELPERASSEMBLY, DefaultValue = ConfigPropertyValue.HELPERASSEMBLY_DEFAULT)]
        public string HelperAssembly
        {
            get
            {
                if (base[ConfigPropertyName.HELPERASSEMBLY] == null || base[ConfigPropertyName.HELPERASSEMBLY].ToString() == "")
                {
                    base[ConfigPropertyName.HELPERASSEMBLY] = ConfigPropertyValue.HELPERASSEMBLY_DEFAULT;
                }
                return (string)base[ConfigPropertyName.HELPERASSEMBLY];
            }
            set
            {
                base[ConfigPropertyName.HELPERASSEMBLY] = value;
            }
        }

        /// <summary>
        /// 指定数据库操作类
        /// </summary>
        [ConfigurationProperty(ConfigPropertyName.HELPERTYPE, DefaultValue = ConfigPropertyValue.HELPERTYPE_DEFAULT)]
        public string HelperType
        {
            get
            {
                if (base[ConfigPropertyName.HELPERTYPE] == null || base[ConfigPropertyName.HELPERTYPE].ToString() == "")
                {
                    base[ConfigPropertyName.HELPERTYPE] = ConfigPropertyValue.HELPERTYPE_DEFAULT;
                }
                return (string)base[ConfigPropertyName.HELPERTYPE];
            }
            set
            {
                base[ConfigPropertyName.HELPERTYPE] = value;
            }
        }

        /// <summary>
        /// 是否调试模式
        /// </summary>
        [ConfigurationProperty(ConfigPropertyName.DEBUGMODE, DefaultValue = ConfigPropertyValue.DEBUG_MODE_DEFAULT)]
        public bool DebugMode
        {
            get
            {
                if (base[ConfigPropertyName.DEBUGMODE] == null || base[ConfigPropertyName.DEBUGMODE].ToString() == "")
                {
                    base[ConfigPropertyName.DEBUGMODE] = ConfigPropertyValue.DEBUG_MODE_DEFAULT;
                }
                return (bool)base[ConfigPropertyName.DEBUGMODE];
            }
            set
            {
                base[ConfigPropertyName.DEBUGMODE] = value;
            }
        }
        /// <summary>
        /// 执行时间日志
        /// </summary>
        [ConfigurationProperty(ConfigPropertyName.LOGEXETIME, DefaultValue = ConfigPropertyValue.LOGEXETIME_DEFAULT)]
        public long LogExeTime
        {
            get
            {
                if (base[ConfigPropertyName.LOGEXETIME] == null || base[ConfigPropertyName.LOGEXETIME].ToString() == "")
                {
                    base[ConfigPropertyName.LOGEXETIME] = ConfigPropertyValue.LOGEXETIME_DEFAULT;
                }
                return (long)base[ConfigPropertyName.LOGEXETIME];
            }
            set
            {
                base[ConfigPropertyName.LOGEXETIME] = value;
            }
        }
        /// <summary>
        /// 是否启用日志
        /// </summary>
        [ConfigurationProperty(ConfigPropertyName.ENABLELOG, DefaultValue = ConfigPropertyValue.ENABLELOG_DEFAULT)]
        public bool EnabledLog
        {
            get
            {
                if (base[ConfigPropertyName.ENABLELOG] == null || base[ConfigPropertyName.ENABLELOG].ToString() == "")
                {
                    base[ConfigPropertyName.ENABLELOG] = ConfigPropertyValue.ENABLELOG_DEFAULT;
                }
                return (bool)base[ConfigPropertyName.ENABLELOG];
            }
            set
            {
                base[ConfigPropertyName.ENABLELOG] = value;
            }
        }
    }
}
